﻿layui.config({
    base: "Scripts/"
}).use(['form', 'layer', 'layedit'], function () {
    var form = layui.form(),
		layer = layui.layer,
		$ = layui.jquery;
    //自定义验证规则
    form.verify({
        UserName: function (value) {
            if (value.length == 0) {
                return '请输入用户名/工号';
            }
        }
      , UserPass: [/(.+){6,12}$/, '密码必须6到12位']
      , VerificationCode: function (value) {
          if (value.length == 0) {
              return '请输入验证码';
          }
      }
    });
    //跟新验证码
    var submitMakePlan = {
        makePlanSubmit: function (data) {
            $.ajax({
                type: "POST",
                url: "/Employment/MakePlan",//发送请求
                data: data.field,
                dataType: "json",
                success: function (result) {
                    if (result.State == 1)
                        layer.alert(result.Message, { icon: 7 });
                    else
                        layer.msg(result.Message, { icon: 1 }, function (index) {
                            layer.close(index);
                        });
                }
            });
        }
    };
    //监听提交
    form.on('submit(makeForm)', function (data) {
        submitMakePlan.makePlanSubmit(data);
        return false;
    });

});